<?php

namespace App\Http\Controllers\Api;

use App\Model\Lesson;
use App\Model\LessonTag;
use App\Model\Slider;
use App\Model\Tag;
use App\Model\Video;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class CotentController extends CommontController
{
    public function tags(){
        return $this->response(Tag::get(),200);
    }
    public function lesson($tid){
        if($tid)
        {
           $lessoinids=LessonTag::where("tag_id",$tid)->pluck("lesson_id");
           $data=Lesson::whereIn("id",$lessoinids)->get();
        }else
        {
            $data=Lesson::get();
        }
        return $this->response($data);
    }
    public function commendLesson($row){
        $data=Lesson::where("is_commend",1)->limit($row)->get();
        return $this->response($data);
    }
    public function hotLesson($row){
        $data=Lesson::where("is_hot",1)->limit($row)->get();
        return $this->response($data);
    }
    public function videos($lessionId){
      $data=Video::where("lesson_id",$lessionId)->get();
      return $this->response($data);
    }
    public function slider()
    {
        $data=Slider::get();
        return $this->response($data);
    }
}
